package com.project.controller;

import com.project.entity.Expert;
import com.project.entity.Question;
import com.project.entity.Result;
import com.project.service.ExpertService;
import com.project.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("expert")
public class ExpertController {
    @Autowired
    private ExpertService expertService;

    @GetMapping("/findPage/{pageIndex}/{pageItemCount}")
    public Result findAll(@PathVariable int pageIndex,@PathVariable int pageItemCount){
        Result result = new Result();
        try {
            List<Expert> expertList = expertService.findPage(pageIndex, pageItemCount);
            result.success("成功");
            result.putData("expertList",expertList);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    @GetMapping("total")
    public Result findAllNum(){
        Result result = new Result();
        try {
            result.success("成功");
            result.putData("num",expertService.findAllNum());
        }catch (Exception e) {
            e.printStackTrace();
            result.error("错误");
        }

        return result;
    }

}
